﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExercisesForLINQ
{
    class Program
    {
        static IEnumerable<Student> FindStudentsWithFirstNameBeforeLast(Student[] studentArray)
        {
            var query =
                from student in studentArray
                where student.FirstName.CompareTo(student.LastName) < 0
                select student;

            return query;
        }

        static IEnumerable<Student> FindStudentsWithAgeInRange(Student[] studentArray, int fromAge,int toAge)
        {
            var query =
                from student in studentArray
                where (student.Age >= fromAge && student.Age <= toAge)
                select student;

            return query;
        }

        static IEnumerable<Student> OrderdStudentsInDecreasingWithLINQ(Student[] studentArray)
        {
            var querySortStudents =
                from student in studentArray
                orderby student.FirstName descending
                orderby student.LastName descending
                select student;

            return querySortStudents;
        }

        static IEnumerable<Student> OrderStudentsInDecresingWithLambdaExp(Student[] studentArray)
        {
            return studentArray.OrderByDescending(Student => Student.FirstName).ThenByDescending(Student => Student.LastName);
        }

        static void PrintAllNumbersDivisibaleByWhithLambdaExp(int[] array, int divider1, int divider2)
        {
            array.ToList<int>().FindAll((x) => (x % divider1 == 0 && x % divider2 == 0));
            foreach (int item in array)
            {
                Console.WriteLine(item);
            }
        }

        static void PrintAllNumbersDivisibleByWithLINQ(int[] array, int divider1, int divider2)
        {
            var query =
                from number in array
                where (number % divider1 == 0 && number % divider2 == 0)
                select number;

            foreach (var item in query)
            {
                Console.WriteLine(item);
            }
        }

        static void Main()
        {
            Student[] students = {
                                     new Student("Goshko", "Hubaveca", 12), 
                                     new Student("Pesho", "Pingvina", 88),
                                     new Student("Kolio", "Kolev", 22),
                                     new Student("Norka", "Maninkata", 54)
                                 };
        }
    }
}
